//
// Copyright (c) 2011 Alex Nesterenko
//

#ifndef NANE_XAUDIO2SOUNDSYSTEM_H
#   define  NANE_XAUDIO2SOUNDSYSTEM_H

#   include "nane/SoundSystem/ISoundSystem.h"
#   include <XAudio2.h>

namespace nane 
{
    
    class XAudio2SoundSystem
        : public ISoundSystem
    {
    public:
        XAudio2SoundSystem();
        ~XAudio2SoundSystem();
        
    public:
        bool initialize();
        void shutdown();
        bool initializeContext( float _speedOfSound );
        void shutdownContext();
        ISoundBuffer* createSoundBuffer( ESoundFormat::raw_type _format, uint32 _frequency, uint32 _channels
                                                , uint32 _bitsPerSample, uint32 _size );
        byte* lockSoundBuffer( ISoundBuffer* _buffer );
        void unlockSoundBuffer( ISoundBuffer* _buffer );
        void releaseSoundBuffer( ISoundBuffer* _buffer );
        
        ISoundSource* createSoundSource();
       // virtual ISoundSource3D* createSoundSource3D() = 0;
       // virtual void setSourcePosition( ISoundSource3D* _source, float _x, float _y, float _z ) = 0;
        bool queueSourceBuffer( ISoundSource* _source, ISoundBuffer* _buffer );
        uint32 getSourceBuffersQueued( ISoundSource* _source );
        void clearSourceBufferQueue( ISoundSource* _source );
        void play( ISoundSource* _source );
        void stop( ISoundSource* _source );
        void releaseSoundSource( ISoundSource* _source );
        
    private:
        IXAudio2* m_pXAudio2;
        IXAudio2MasteringVoice* m_pMasteringVoice;
    };
}   // namespace nane

#endif	// NANE_XAUDIO2SOUNDSYSTEM_H
